﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Xml.Linq;
using Microsoft.VisualStudio.Tools.Applications.Runtime;
using Excel = Microsoft.Office.Interop.Excel;
using Office = Microsoft.Office.Core;
//using Bds.Inject;

namespace NewFarpac
{
    public partial class Master
    {
        private void Sheet1_Startup(object sender, System.EventArgs e)
        {
        }

        private void Sheet1_Shutdown(object sender, System.EventArgs e)
        {
        }

        #region VSTO Designer generated code

        /// <summary>
        /// Required method for Designer support - do not modify
        /// the contents of this method with the code editor.
        /// </summary>
        private void InternalStartup()
        {
            this.butSummit.Click += new System.EventHandler(this.butSummit_Click);
            this.Startup += new System.EventHandler(this.Sheet1_Startup);
            this.Shutdown += new System.EventHandler(this.Sheet1_Shutdown);

        }

        #endregion

        private void butSummit_Click(object sender, EventArgs e)
        {
            
            /*
            foreach (Excel.Names name in Globals.ThisWorkbook.Names)
            {
                MessageBox.Show(name.ToString());
            }*/
            
            return;

            DienLib.PopUp.PopUpResult butMsg = DienLib.PopUp.PopUpOKCancel.ShowDialog("Highly recommend you \"close ALL Open Window FIRST\" before Click OK !", "Demo \"Auto fill SUMMIT Job Package\"");
            if (butMsg == DienLib.PopUp.PopUpResult.CANCEL) return;

            //IntPtr hWnd = DienLib.SummitLib.Command.StartSummit();
            // http://blogs.msdn.com/b/suzcook/archive/2003/06/26/assembly-codebase-vs-assembly-location.aspx // So better not use CodeBase but Location instead
            string DemoSummitWPF_dll = new Uri(System.Reflection.Assembly.GetAssembly(typeof(DienVu.MainWindow)).CodeBase).LocalPath;
            DienLib.PopUp.PopUpOK.ShowDialog(System.Reflection.Assembly.GetAssembly(typeof(DienVu.MainWindow)).Location, "Location of DemoSummitWPF.dll");

            DienLib.ReportLib.Configuration _config = new DienLib.ReportLib.Configuration(@"C:\HalReport\config.xlsx");
            DienLib.ReportLib.FarPac farpac;
            try { farpac = new DienLib.ReportLib.FarPac(Globals.ThisWorkbook.FullName, _config); }
            catch (Exception ex) { MessageBox.Show("Not a FARPAC file or unsupported version ! Please try another !\r\n" + ex.Message, "NOT SUPPORTED FARPAC VERSION"); }

            //DemoSummitWPF_dll = System.Reflection.Assembly.GetAssembly(typeof(DienVu.MainWindow)).Location;
            //Injector.InvokeRemote(hWnd, DemoSummitWPF_dll, "DienVu.MainWindow", "ShowForm", new object[] { hWnd, @"C:\HalReport\config.xlsx", Globals.ThisWorkbook.FullName }); // Config to Load Database, other stuffd
        }

        const string MASTER_VERSION = "Master_Version";
        const string MASTER_TICKETNO = "Master_TicketNo";
        const string MASTER_JOBDATE = "Master_JobDate";
        const string MASTER_FIELD = "Master_Field";
        const string MASTER_LOCATION = "Master_Location";
        const string MASTER_PROVINCE = "Master_Province";
        const string MASTER_COUNTRY = "Master_Country";
        const string MASTER_WELLNAME = "Master_WellName";
        const string MASTER_CLIENT = "Master_Client";
        const string MASTER_RIGPLATFORM = "Master_RigPlatform";
        const string MASTER_UNITNO = "Master_UnitNo";
        const string MASTER_BOM = "Master_BOM";
        const string MASTER_ENGINEERS = "Master_Engineers";
        const string MASTER_ENGINEERSAP = "Master_EngineerSAPs";
        const string MASTER_CREWCHIEFS = "Master_CrewChiefs";
        const string MASTER_OPERATORS = "Master_Operators";
        const string MASTER_CREW1 = "Master_Crew1";
        const string MASTER_CREW2 = "Master_Crew2";
        const string MASTER_CREW3 = "Master_Crew3";
        const string MASTER_CREW4 = "Master_Crew4";
        const string MASTER_HESPERSONNEL = "Master_PersonHES";
        const string MASTER_COMAN = "Master_CoMans";
        const string MASTER_JOBTYPE = "Master_JobType";
        const string MASTER_HOLETYPE = "Master_HoleType";
        const string MASTER_DRILLDEPTH = "Master_DrillDepth";
        const string MASTER_JOBMD = "Master_JobMD";
        const string MASTER_JOBTVD = "Master_JobTVD";
        const string MASTER_CASINGSIZE = "Master_CasingSize";
        const string MASTER_CASINGDEPTH = "Master_CasingDepth";
        const string MASTER_BHT = "Master_BHT";
        const string MASTER_WHP = "Master_WHP";
        const string MASTER_WELLFLUID = "Master_WellFluid";
        const string MASTER_FLUIDGRAVITY = "Master_FluidGravity";
        const string MASTER_FLUIDLEVEL = "Master_FluidLevel";
        const string MASTER_BITSIZE = "Master_BitSize";
        const string MASTER_MINID = "Master_MinID";
        const string MASTER_MINID_DEPTH = "Master_MinID_Depth";
        const string MASTER_MAXDEV = "Master_MaxDEV";
        const string MASTER_MAXDEV_DEPTH = "Master_MaxDEV_Depth";
        const string MASTER_KOP = "Master_KOP";
        const string MASTER_MAXDL = "Master_MaxDL";
        const string MASTER_MAXDL_DEPTH = "Master_MaxDL_Depth";
        const string MASTER_TDDEV = "Master_TDdev";
        const string MASTER_TDDIR = "Master_TDdir";
        const string MASTER_CORLOG_DESC = "Master_CorLog_Desc";
        const string MASTER_CORLOG_DATE = "Master_CorLog_Date";
        const string MASTER_RUNALL = "Master_RunAll";
        const string MASTER_RUNBASIC = "Master_RunBasic";
        const string MASTER_RUNNORMAL = "Master_RunNormal";
        const string MASTER_CABLEDRUMS = "Master_CableDrums";

        private void ReadMaster()
        {

        }
    }
}
